<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2018/8/16
 * Time: 17:14
 */

namespace app\modules\controllers;

use Yii;
use app\modules\models\Admin;
use yii\web\Controller;

class PublicController extends Controller
{

     public function actionLogin()
     {
         $model = new Admin();
         if (\Yii::$app->request->isPost){
             if($model->login(Yii::$app->request->post())){
                 return $this->redirect(['default/index']);
             }
         }
         return $this->renderPartial('login',['model' => $model]);
     }

     public function actionLogout()
     {
         \Yii::$app->admin->logout(false);
         return $this->goBack();
     }
    public function actionSeekpassword()
    {
        $this->layout = false;
        $model = new Admin;
        if (Yii::$app->request->isPost) {
            $post = Yii::$app->request->post();
            if ($model->seekPass($post)) {
                Yii::$app->session->setFlash('info', '电子邮件已经发送成功，请查收');
            }
        }
        return $this->render("seekpassword", ['model' => $model]);
    }

}